package com.chy.order_meal.dao;

import com.chy.order_meal.po.Resturant;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public interface ResturantDao extends JpaRepository<Resturant,Integer> {

    @Query("select e from Resturant e ORDER BY e.recentOrderNum DESC ")
    List<Resturant> getPageByRecentOrderNum(Pageable pageable);

    @Query(nativeQuery=true,value = "select t.* from t_resturant t " +
            "RIGHT JOIN " +
            "(select ca.resturant_id as id from t_channel_cat2res ca where ca.categories_id in :ids) as t1 " +
            "ON " +
            "t.elm_id = t1.id ")
   List<Resturant> getPageByType(@Param("ids") List ids,Pageable pageable);

}
